package com.medical.patient.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.medical.patient.entity.PatientMedicalRecordEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.medical.patient.entity.PatientDiagnoseEntity;
import com.medical.patient.service.PatientDiagnoseService;
import com.medical.common.utils.PageUtils;
import com.medical.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2021-08-13 18:42:36
 */
@RestController
@RequestMapping("patient/patientdiagnose")
public class PatientDiagnoseController {
    @Autowired
    private PatientDiagnoseService patientDiagnoseService;

    @RequestMapping("test")
    public String test(){
        return "http://127.0.0.1:5501/index.html";
    }



    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = patientDiagnoseService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * patientid查询患者就诊信息
     */
    @RequestMapping("/findByPatientId/{diagnoseId}")
    public R findByPatientId(@PathVariable("diagnoseId") Integer diagnoseId){
        List<PatientDiagnoseEntity> patientDiagnoseServiceList = patientDiagnoseService.getByDiagnoseId(diagnoseId);

        return R.ok().put("patientDiagnoseServiceList", patientDiagnoseServiceList);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{diagnoseId}")
    public R info(@PathVariable("diagnoseId") Integer diagnoseId){
        PatientDiagnoseEntity patientDiagnose = patientDiagnoseService.getById(diagnoseId);

        return R.ok().put("patientDiagnose", patientDiagnose);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody PatientDiagnoseEntity patientDiagnose){
		patientDiagnoseService.save(patientDiagnose);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody PatientDiagnoseEntity patientDiagnose){
		patientDiagnoseService.updateById(patientDiagnose);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] diagnoseIds){
		patientDiagnoseService.removeByIds(Arrays.asList(diagnoseIds));

        return R.ok();
    }

}
